package com.yubb.framework.filter;

import com.baomidou.mybatisplus.core.parser.ISqlParserFilter;
import com.yubb.common.utils.ServletUtils;
import com.yubb.framework.config.properties.TenantFilterProperties;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 *@Description 实现mybatis-plus的租户过滤起
 *@Author zhushuyong
 *@Date 2021/6/24 22:34
 *@since:
 *@copyright: 版权所有2021 开源组织 gitee(https://gitee.com/jinzheyi)作者：朱述勇<br/>
 *            GitHub(https://github.com/jinzheyi)作者：朱述勇 。
 */
@Component
public class YubbSqlParserFilter implements ISqlParserFilter {

    @Resource
    private TenantFilterProperties tenantFilterProperties;

    /**
     * 重写mybatis-plus多租户过滤器
     * @param metaObject
     * @return
     */
    @Override
    public boolean doFilter(MetaObject metaObject) {
        HttpServletRequest request = ServletUtils.getRequest();
        boolean logoutStatus = request.getRequestURI().contains("/logout");
        if (logoutStatus){
            return true;
        }
        return false;
    }

}
